<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
  <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import = "ServiceImpl.UserCarServiceImpl" %>
<%@ page import = "ServiceImpl.InfoServiceImpl" %>
<%@ page import = "Bean.User" %>
<%@ page import = "Bean.Info" %>
<%@ page import = "Bean.UserAndCar" %>
<%@ page import = "java.util.List" %>
<%@ page import = "java.util.ArrayList" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>info</title>
		<link type="text/css" href="assets/css/bootstrap.min.css" rel="stylesheet">
    	<!-- <link rel="stylesheet" href="css\font-awesome.min.css"> -->
    	<script src="assets/js/jquery-3.2.1.js"></script>
    	<script src="assets/js/bootstrap.min.js"></script>
	</head>
	<body>
	<jsp:include page="nav.jsp"/>
	<div class="container-fluid">
    <div class="row">
    <div class="col-md-3">
    <div class="list-group">
      <a href="#" class="list-group-item active" target="test">我的车牌</a>
    </div>
</div>
      <div class="col-md-9">
		<% 
			User user = (User)request.getSession().getAttribute("nowUser");
			String username = user.getUsername(); 
		%>
		<%-- 当前账户：${ username } --%>
		<!-- <form action = "login.jsp" method = "post"> 
			<input type = "submit" value = "退出登录" />
		</form> -->
		
		
	
		<%-- <form action = "http://localhost:8083/Car_Pass_Count_System/update_user.jsp?username=${ username }" method = "post">
			<input type = "submit" value = "更改账户密码" />
		</form> --%>
		
		
		
		<%
			UserCarServiceImpl userCarService = new UserCarServiceImpl();
			InfoServiceImpl infoServiceImpl = new InfoServiceImpl();
			List<UserAndCar> list = userCarService.selectAllCarOfUser(username);
			/* out.println(list); */
			List<Info> infoList = new ArrayList<Info>();
			for(UserAndCar userAndCar : list) {
				infoList.add(infoServiceImpl.selectAllInfoByCarId(userAndCar.getCar_id()));
			}
			// out.println(infoList);
			pageContext.setAttribute("infoList", infoList);
		%> 
		<table border = "3" >
		<tr>
			<th> 车牌 </th>
			<th> 最近进入时间</th>
			<th> 最近离开时间 </th>
		</tr>
			<c:forEach items="${infoList}" var="t">
				<tr>
					<td>
						${ t.car_id }
					</td>
					<td>
						${ t.in_info }
					</td>
					<td>
						${ t.out_info }
					</td>
				</tr>
			</c:forEach>
		</table>




      </div>
    </div>
  </div>
	</body>
</html>